/**
 * 一些静态配置
 */

/**
 * 热词
 */
export const hotKey = {
	keyWords: [],
	methods: [],
}

const defaultValueConst = [{
	name: 'NULL',
	value: 'NULL'
},
{
	name: '空字符串',
	value: 'EMPTY_STRING'
}
]

export const sortType = [{
		name: 'ASC',
		value: 'ASC'
	},
	{
		name: 'DESC',
		value: 'DESC'
	}
]

/**
 * 索引类型
 */
export const indexType = [{
	name: "FULLTEXT",
	value:"FULLTEXT"
}, {
	name: "NORMAL",
	value: "NORMAL"
}, {
	name: "SPATIAL",
	value: "SPATIAL"
}, {
	name: "UNIQUE",
	value: "UNIQUE"
}]

/**
 * 索引类型
 */
 export const foreignKeyActionType = [{
	name: "CASCADE",
	value:"CASCADE"
}, {
	name: "NO ACTION",
	value: "NO ACTION"
}, {
	name: "RESTRICT",
	value: "RESTRICT"
}, {
	name: "SET NULL",
	value: "SET NULL"
}]

export const triggerType = [{
	name:'AFTER',
	value:"AFTER"
},
{
	name:'BEFORE',
	value:"BEFORE"
}]

export const triggerTimeType = [{
	name:'INSERT',
	value:"INSERT"
},
{
	name:'UPDATE',
	value:"UPDATE"
},{
	name:'DELETE',
	value:"DELETE"
}]

/**
 * 索引类型
 */
export const indexMethod = [{
	name: "BTREE",
	value: "BTREE"
}, {
	name: "HASH",
	value: "HASH"
}]

/**
 * 数据类型
 */
export const dataType = [{
	name: 'bigint',
	size: 255,
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	${row.auto_increment ? 'auto_increment' : ''} ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'binary',
	size: 255,
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}],

	buildSql: (row) => {
		debugger
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'} ${emptyStr} ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'bit',
	size: 64,
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}],

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'} ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'blob',
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}],

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'} 
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'char',
	size: 255,
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}, {
		name: '二进制',
		key: 'BINARY',
		type: 'checkbox'
	}],


	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.BINARY ? 'BINARY' : ''} ${row.CHARSET ? `SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}


}, {
	name: 'date',
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}],

	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'datetime',
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '根据当前时间戳更新',
		key: 'CURRENT_TIMESTAMP',
		type: 'checkbox'
	}],

	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''}   ${row.nullable ? 'NULL' : 'NOT NULL'} 
			 ${emptyStr} ${row.CURRENT_TIMESTAMP ? `ON UPDATE CURRENT_TIMESTAMP` : ''} ${row.CURRENT_TIMESTAMP ? `${row.size ? `(${row.size})` : ''}` : ''} 
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'decimal',
	size: 65,
	decimalDigits: 30,
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size}${row.decimalDigits ? `,${row.decimalDigits}` : ''})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'double',
	defaultSize: 10,
	defaultDecimalDigits: 2,
	size: 30,
	decimalDigits: 30,
	other: [{
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return `${row.type}${row.size ? `(${row.size}${row.decimalDigits ? `,${row.decimalDigits}` : ''})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	${row.auto_increment ? 'auto_increment' : ''} ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'enum',
	other: [{
		name: "值",
		key: 'enumValue',
		type: 'input',
	}, {
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}],

	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.enumValue ? `enum(${row.enumValue})` : ''}  ${row.CHARSET ? `CHARACTER SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},
	/**
	 * 
	 * @param {原始数据} data 
	 * @param {转换数据} row 
	 */
	parserField: (data, row) => {
		if (data.COLUMN_TYPE) {
			const matchResult = data.COLUMN_TYPE.match(/\(.*?\)/g)
			if (!matchResult || matchResult.length == 0) {
				return;
			}
			row.enumValue = matchResult[0].replace("(", "").replace(")", "");
		}

	}

}, {
	name: 'float',
	size: 255,
	decimalDigits: 30,
	other: [{
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size}${row.decimalDigits ? `,${row.decimalDigits}` : ''})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	${row.auto_increment ? 'auto_increment' : ''} ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'geometry',
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'geometrycollection',

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'int',
	other: [{
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	${row.auto_increment ? 'auto_increment' : ''} ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'integer',
	toType: 'int',
	other: [{
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	${row.auto_increment ? 'auto_increment' : ''} ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'json',
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'linestring',
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'longblob',
	other: [{
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'longtext',
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}, {
		name: '二进制',
		key: 'BINARY',
		type: 'checkbox'
	}],
	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.BINARY ? 'BINARY' : ''} ${row.CHARSET ? `CHARACTER SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'mediumblob',
	other: [{
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'mediumint',
	other: [{
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	${row.auto_increment ? 'auto_increment' : ''} ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}


}, {
	name: 'mediumtext',
	other: [{
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}, {
		name: '二进制',
		key: 'BINARY',
		type: 'checkbox'
	}],
	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.BINARY ? 'BINARY' : ''} ${row.CHARSET ? `CHARACTER SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'multilinestring',
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'multipoint',

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'multipolygon',
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'numeric',
	toType: 'decimal',
	other: [{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size}${row.decimalDigits ? `,${row.decimalDigits}` : ''})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}  ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'point',

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'polygon',

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'real',
	other: [{
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size}${row.decimalDigits ? `,${row.decimalDigits}` : ''})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr} ${row.auto_increment ? 'auto_increment' : ''}		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},
	

}, {
	name: 'set',
	other: [{
		name: "值",
		key: 'enumValue',
		type: 'input',
	}, {
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}],
	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''}  ${row.CHARSET ? `CHARACTER SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},
	/**
	 * 
	 * @param {原始数据} data 
	 * @param {转换数据} row 
	 */
	parserField: (data, row) => {
		if (data.COLUMN_TYPE) {
			const matchResult = data.COLUMN_TYPE.match(/\(.*?\)/g)
			if (!matchResult || matchResult.length == 0) {
				return;
			}
			row.enumValue = matchResult[0].replace("(", "").replace(")", "");
		}
	}

}, {
	name: 'smallint',
	other: [{
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size}${row.decimalDigits ? `,${row.decimalDigits}` : ''})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr} ${row.auto_increment ? 'auto_increment' : ''}		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},
	


}, {
	name: 'text',
	other: [{
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}, {
		name: '二进制',
		key: 'BINARY',
		type: 'checkbox'
	}],
	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.BINARY ? 'BINARY' : ''} ${row.CHARSET ? `CHARACTER SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},

}, {
	name: 'time',

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}
}, {
	name: 'timestamp',
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '根据当前时间戳更新',
		key: 'CURRENT_TIMESTAMP',
		type: 'checkbox'
	}],

	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''}   ${row.nullable ? 'NULL' : 'NOT NULL'} 
			 ${emptyStr} ${row.CURRENT_TIMESTAMP ? `ON UPDATE CURRENT_TIMESTAMP` : ''} ${row.CURRENT_TIMESTAMP ? `${row.size ? `(${row.size})` : ''}` : ''} 
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},


}, {
	name: 'tinyblob',
	other: [{
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'tinyint',
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	}, {
		name: '自动递增',
		key: 'auto_increment',
		type: 'checkbox'
	},
	{
		name: '无符号',
		key: 'unsigned',
		type: 'checkbox'
	}, {
		name: '填充零',
		key: 'zerofill',
		type: 'checkbox'
	}
	],

	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size}${row.decimalDigits ? `,${row.decimalDigits}` : ''})` : ''} ${row.unsigned ? 'UNSIGNED' : ''} ${row.zerofill ? 'ZEROFILL' : ''} ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr} ${row.auto_increment ? 'auto_increment' : ''}		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},



}, {
	name: 'tinytext',
	other: [{
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}, {
		name: '二进制',
		key: 'BINARY',
		type: 'checkbox'
	}],

	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.BINARY ? 'BINARY' : ''} ${row.CHARSET ? `CHARACTER SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},



}, {
	name: 'varbinary',
	size: 65535,
	other: [{
		name: '默认值',
		key: 'column_default',
		type: 'select',
		data: (row) => {
			return defaultValueConst
		}
	},
	{
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}
	],
	buildSql: (row) => {
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}  ${row.nullable ? 'NULL' : 'NOT NULL'}
	${emptyStr}	 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	}

}, {
	name: 'varchar',
	defaultSize: 255,
	size: 65535,
	other: [{
		name: '字符集',
		key: 'CHARSET',
		type: 'select',
		data: (row) => {
			characterSets.forEach(element => {
				element.value = element.name
			});
			return characterSets;
		}
	}, {
		name: '排序规则',
		key: 'COLLATION',
		type: 'select',
		data: (row) => {
			const childrenList = characterSets.filter(item => item.name == row.CHARSET);
			if (childrenList && childrenList.length > 0) {
				const list = childrenList[0].children;
				list.forEach(element => {
					element.value = element.name
				});
				return list;
			}
			return [];
		}
	}, {
		name: '键长度',
		key: 'KEY_LENGHT',
		type: 'number',
		disabled: (row) => {
			return !row.primaryKey;
		}
	}, {
		name: '二进制',
		key: 'BINARY',
		type: 'checkbox'
	}],

	buildSql: (row) => {
		//char(121) BINARY CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 1212 COMMENT 'SADFASDF' 
		let emptyStr = "";
		if (row.column_default) {
			emptyStr = `DEFAULT ${row.column_default}`;
		}
		if (row.column_default === 'NULL' && !row.nullable) {
			emptyStr = "DEFAULT NULL";
		}
		if (row.column_default === 'EMPTY_STRING') {
			emptyStr = "DEFAULT  ''";
		}
		return ` ${row.type}${row.size ? `(${row.size})` : ''} ${row.BINARY ? 'BINARY' : ''} ${row.CHARSET ? `CHARACTER SET ${row.CHARSET}` : ''}
		${row.COLLATION ? `COLLATE ${row.COLLATION}` : ''}  ${row.nullable ? 'NULL' : 'NOT NULL'}  ${emptyStr}
		 ${row.comment ? `COMMENT  '${row.comment}'` : ''}`
	},



}]
/**
 * 字符集
 */
export const characterSets = [{
	name: 'armscii8',
	children: [{
		name: 'armscii8_bin'
	}, {
		name: 'armscii8_general_ci'
	}],
},
{
	name: 'ascii',
	children: [{
		name: 'ascii_bin'
	}, {
		name: 'ascii_general_ci'
	}],
}, {
	name: 'big5',
	children: [{
		name: 'big5_bin'
	}, {
		name: 'big5_general_ci'
	}],
}, {
	name: 'binary',
	children: [{
		name: 'binary'
	}],
}, {
	name: 'cp850',
	children: [{
		name: 'cp850_bin'
	}, {
		name: 'cp850_general_ci'
	}],
}, {
	name: 'cp852',
	children: [{
		name: 'cp852_bin'
	}, {
		name: 'cp852_general_ci'
	}],
}, {
	name: 'cp866',
	children: [{
		name: 'cp866_bin'
	}, {
		name: 'cp866_general_ci'
	}],
}, {
	name: 'cp932',
	children: [{
		name: 'cp932_bin'
	}, {
		name: 'cp932_japanese_ci'
	}],
}, {
	name: 'cp1250',
	children: [{
		name: 'cp1250_bin'
	}, {
		name: 'cp1250_croatian_ci'
	}, {
		name: 'cp1250_czech_cs'
	}, {
		name: 'cp1250_general_ci'
	}, {
		name: 'cp1250_polish_ci'
	}],
}, {
	name: 'cp1251',
	children: [{
		name: 'cp1251_bin'
	}, {
		name: 'cp1251_bulgarian_ci'
	}, {
		name: 'cp1251_general_ci'
	}, {
		name: 'cp1251_general_cs'
	}, {
		name: 'cp1251_ukrainian_ci'
	}],
}, {
	name: 'cp1256',
	children: [{
		name: 'cp1256_bin'
	}, {
		name: 'cp1256_general_ci'
	}],
}, {
	name: 'cp1257',
	children: [{
		name: 'cp1257_bin'
	}, {
		name: 'cp1257_general_ci'
	}, {
		name: 'cp1257_lithuanian_ci'
	}],
}, {
	name: 'dec8',
	children: [{
		name: 'dec8_bin'
	}, {
		name: 'cp1257_gdec8_swedish_cieneral_ci'
	}],
}, {
	name: 'eucjpms',
	children: [{
		name: 'eucjpms_bin'
	}, {
		name: 'eucjpms_japanese_ci'
	}],
}, {
	name: 'euckr',
	children: [{
		name: 'euckr_bin'
	}, {
		name: 'euckr_korean_ci'
	}],
}, {
	name: 'gb2312',
	children: [{
		name: 'gb2312_bin'
	}, {
		name: 'gb2312_chinese_ci'
	}],
}, {
	name: 'gb18030',
	children: [{
		name: 'gb18030_bin'
	}, {
		name: 'gb18030_chinese_ci'
	}, {
		name: 'gb18030_unicode_520_ci'
	}],
}, {
	name: 'gbk',
	children: [{
		name: 'gbk_bin'
	}, {
		name: 'gbk_chinese_ci'
	}],
}, {
	name: 'geostd8',
	children: [{
		name: 'geostd8_bin'
	}, {
		name: 'geostd8_general_ci'
	}],
}, {
	name: 'greek',
	children: [{
		name: 'greek_bin'
	}, {
		name: 'greek_general_ci'
	}],
}, {
	name: 'hebrew',
	children: [{
		name: 'hebrew_bin'
	}, {
		name: 'hebrew_general_ci'
	}],
}, {
	name: 'hp8',
	children: [{
		name: 'hp8_bin'
	}, {
		name: 'hp8_english_ci'
	}],
}, {
	name: 'keybcs2',
	children: [{
		name: 'keybcs2_bin'
	}, {
		name: 'keybcs2_general_ci'
	}],
}, {
	name: 'koi8r',
	children: [{
		name: 'koi8r_bin'
	}, {
		name: 'koi8r_general_ci'
	}],
}, {
	name: 'koi8u',
	children: [{
		name: 'koi8u_bin'
	}, {
		name: 'koi8u_general_ci'
	}],
}, {
	name: 'latin1',
	children: [{
		name: 'latin1_bin'
	}, {
		name: 'latin1_danish_ci'
	}, {
		name: 'latin1_general_ci'
	}, {
		name: 'latin1_general_cs'
	}, {
		name: 'latin1_german1_ci'
	}, {
		name: 'latin1_german2_ci'
	}, {
		name: 'latin1_spanish_ci'
	}, {
		name: 'latin1_swedish_ci'
	}],
}, {
	name: 'latin2',
	children: [{
		name: 'latin2_bin'
	}, {
		name: 'latin2_croatian_ci'
	}, {
		name: 'latin2_czech_cs'
	}, {
		name: 'latin2_general_ci'
	}, {
		name: 'latin2_hungarian_ci'
	}],
}, {
	name: 'latin5',
	children: [{
		name: 'latin5_bin'
	}, {
		name: 'latin5_turkish_ci'
	}],
}, {
	name: 'latin7',
	children: [{
		name: 'latin7_bin'
	}, {
		name: 'latin7_estonian_cs'
	}, {
		name: 'latin7_general_ci'
	}, {
		name: 'latin7_general_cs'
	}],
}, {
	name: 'macce',
	children: [{
		name: 'macce_bin'
	}, {
		name: 'macce_general_ci'
	}],
}, {
	name: 'macroman',
	children: [{
		name: 'macroman_bin'
	}, {
		name: 'macroman_general_ci'
	}],
}, {
	name: 'sjis',
	children: [{
		name: 'sjis_bin'
	}, {
		name: 'sjis_japanese_ci'
	}],
}, {
	name: 'swe7',
	children: [{
		name: 'swe7_bin'
	}, {
		name: 'swe7_swedish_ci'
	}],
}, {
	name: 'tis620',
	children: [{
		name: 'tis620_bin'
	}, {
		name: 'tis620_thai_ci'
	}],
}, {
	name: 'ucs2',
	children: [{
		name: 'ucs2_bin'
	}, {
		name: 'ucs2_croatian_ci'
	}, {
		name: 'ucs2_czech_ci'
	}, {
		name: 'ucs2_danish_ci'
	}, {
		name: 'ucs2_esperanto_ci'
	}, {
		name: 'ucs2_estonian_ci'
	}, {
		name: 'ucs2_general_ci'
	}, {
		name: 'ucs2_general_mysql500_ci'
	}, {
		name: 'ucs2_german2_ci'
	}, {
		name: 'ucs2_hungarian_ci'
	}, {
		name: 'ucs2_icelandic_ci'
	}, {
		name: 'ucs2_latvian_ci'
	}, {
		name: 'ucs2_lithuanian_ci'
	}, {
		name: 'ucs2_persian_ci'
	}, {
		name: 'ucs2_polish_ci'
	}, {
		name: 'ucs2_roman_ci'
	}, {
		name: 'ucs2_romanian_ci'
	}, {
		name: 'ucs2_sinhala_ci'
	}, {
		name: 'ucs2_slovak_ci'
	}, {
		name: 'ucs2_slovenian_ci'
	}, {
		name: 'ucs2_spanish_ci'
	}, {
		name: 'ucs2_spanish2_ci'
	}, {
		name: 'ucs2_swedish_ci'
	}, {
		name: 'ucs2_turkish_ci'
	}, {
		name: 'ucs2_unicode_520_ci'
	}, {
		name: 'ucs2_unicode_520_ci'
	}, {
		name: 'ucs2_vietnamese_ci'
	}],
}, {
	name: 'ujis',
	children: [{
		name: 'ujis_bin'
	}, {
		name: 'ujis_japanese_ci'
	}],
}, {
	name: 'utf8',
	children: [{
		name: 'utf8_bin'
	}, {
		name: 'utf8_croatian_ci'
	}, {
		name: 'utf8_czech_ci'
	}, {
		name: 'utf8_danish_ci'
	}, {
		name: 'utf8_esperanto_ci'
	}, {
		name: 'utf8_estonian_ci'
	}, {
		name: 'utf8_general_ci'
	}, {
		name: 'utf8_general_mysql500_ci'
	}, {
		name: 'utf8_german2_ci'
	}, {
		name: 'utf8_hungarian_ci'
	}, {
		name: 'utf8_icelandic_ci'
	}, {
		name: 'utf8_latvian_ci'
	}, {
		name: 'utf8_lithuanian_ci'
	}, {
		name: 'utf8_persian_ci'
	}, {
		name: 'utf8_polish_ci'
	}, {
		name: 'utf8_roman_ci'
	}, {
		name: 'utf8_romanian_ci'
	}, {
		name: 'utf8_sinhala_ci'
	}, {
		name: 'utf8_slovak_ci'
	}, {
		name: 'utf8_slovenian_ci'
	}, {
		name: 'utf8_spanish_ci'
	}, {
		name: 'utf8_spanish2_ci'
	}, {
		name: 'utf8_swedish_ci'
	}, {
		name: 'utf8_turkish_ci'
	}, {
		name: 'utf8_unicode_520_ci'
	}, {
		name: 'utf8_unicode_ci'
	}, {
		name: 'utf8_vietnamese_ci'
	}],
}, {
	name: 'utf8mb4',
	children: [{
		name: 'utf8mb4_bin'
	}, {
		name: 'utf8mb4_general_ci'
	}],
}, {
	name: 'utf16',
	children: [{
		name: 'utf16_bin'
	}],
}, {
	name: 'utf16le',
	children: [{
		name: 'utf16le_bin'
	}],
}, {
	name: 'utf32',
	children: [{
		name: 'utf32_bin'
	}],
}


]


/**
 * 
 * @param {转换配置} coverConfig 
 * @param {链接id} connId 
 * @param {数据库} catalog 
 * @param {表名字} tableName 
 * @param {获取回来的数据} data 
 */
export const metadataCovert = (opt, covert, res, connId,catalog,tableName) => {
	if (!res) {
		return [];
	}
	if (!res.success) {
		opt.message.error(res.message);
		return [];
	}
	const rows = res.rows;
	const result = [];
	for (const row of rows) {
		result.push(rowCovert(covert, row, connId,catalog,tableName))
	}
	return result;
}

export const rowCovert = (covert, row, connId,catalog,tableName) => {
	const d = metaDefaultConfg(connId,catalog,tableName)
	covert(d, row, connId,catalog,tableName);
	d.properties = Object.assign(d.properties, row)
	return d;
}

export const metaDefaultConfg = (connId,catalog,tableName) => {
	
	const d = {};
	d.leaf = false;
	d.properties = {};
	d.properties.pluginId = 'mysql'
	d.properties.connId = connId;
	d.properties.catalog = catalog;
	d.properties.tableName = tableName;
	return d;
}
